<template>
  <Modal
    v-model="visibel"
    :title="`等级变更 ${editForm.nickName}`"
    @on-ok="ok"
    @on-cancel="cancel"
  >
    <Form
      :model="editForm"
      :label-width="80"
      :rules="ruleValidate"
      ref="formValidate"
    >
      <FormItem label="等级" prop="gradeId">
        <Select v-model="editForm.gradeId" style="width: 200px">
          <Option
            v-for="item in gradeArrays"
            :value="item.value"
            :key="item.value"
            >{{ item.text }}</Option
          >
        </Select>
      </FormItem>
    </Form>
  </Modal>
</template>

<script>
import * as API_Member from "@/api/member.js";
import { getDictByKey } from "@/libs/dictStorage";
const gradeDictData = getDictByKey("memberGrade");

export default {
  data() {
    return {
      visibel: false,
      editForm: {},
      gradeArrays: gradeDictData,
      ruleValidate: {
        gradeId: [{ required: true, message: "请选择等级!", trigger: "blur" }],
      },
    };
  },
  methods: {
    show(obj) {
      this.editForm = { ...obj };
      this.visibel = true;
    },
    cancel() {
      this.cancel = false;
    },
    ok() {
      this.$refs.formValidate.validate((valid) => {
        if (valid) {
          API_Member.updateMember(this.editForm).then((res) => {
            if (res.result) {
              this.$Message.success("修改成功！");
              this.$emit("reloadData");
            } else {
            }
          });
        } else {
        }
      });
    },
  },
};
</script>

<style></style>
